local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.OHOHOLYBUIBase());
local CallBackManager = ClientOHOH.load.CallBackManager();
local CommonOHOH =_G.CommonOHOH;
local LanguageHelper=_G.LanguageHelper;
function InitInsts(ui)
    ui.insts = {};
    ui.insts.Close = "ctrl.close";
    ui.insts.Buy ={
        btn= "ctrl.btn.btn_buy",
        price = "ctrl.btn.price_buy",
    }
    ui.insts.Receive= {
        btn="ctrl.btn.btn_receive",
        text = "ctrl.btn.txt_receive"
        -- count="ctrl.btn.free_count"
    }
    ui.insts.Task= {
        title="ctrl.progress.title",
        onLineTime="ctrl.progress.time",
        progress="ctrl.progress.bar",
    }
    ui.insts.Rewards= {
        diamond="ctrl.prize.diamond",
        potions="ctrl.prize.potions",
        tvMan="ctrl.prize.tvMan",
    }
end;
function M.new(...)
	return M(...);
end;

function M.ctor(self)
    InitInsts(self);
    M.super.ctor(self, ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.QuestGui"));

    self.ReceiveEvent=_G.CommonOHOH.load.Connect().new()
    self.BuyEvent=_G.CommonOHOH.load.Connect().new()
    
    CallBackManager:AddRbxConnect(self,self.insts.Close.Activated, function()
        self:Hide();
	end);

    CallBackManager:AddRbxConnect(self,self.insts.Buy.btn.Activated, function()
        self.BuyEvent:Action()
	end);

    CallBackManager:AddRbxConnect(self,self.insts.Receive.btn.Activated, function()
        self.ReceiveEvent:Action()
	end);
end;
function M.Init(self,count,price,list)
    self.Count=count--完成所需分钟数
    self.insts.Task.progress.Size=UDim2.fromScale(0,1)
    self:FullText(self.insts.Task.title,{count})
    self.insts.Receive.text.Text=LanguageHelper:GetText(30038)
    self.insts.Rewards.diamond.Text= string.format("x%s",list["base_meat"] )
    self.insts.Rewards.potions.Text= string.format("x%s", list["buff_damge_2_30"] )
    self.insts.Buy.price.Text = price
    self.insts.Rewards.tvMan.Text= string.format("x%s",list["pets_9999003"]  )
   
end

function M.UpdateProgress(self,percent)
    self.insts.Task.progress.Size=UDim2.fromScale(percent,1)
end
function M.UpdateTime(self,str)
    self.insts.Task.onLineTime.Text=str
end
function M.ClearTask(self)
     --显示 ：已完成 领取
    self.insts.Receive.text.Text=LanguageHelper:GetText(8)
    self.insts.Task.onLineTime.Text=LanguageHelper:GetText(33406)
end
function M.Claimed(self)
    --显示：已领取
    self.insts.Task.onLineTime.Text=LanguageHelper:GetText(10404)
    self.insts.Receive.text.Text=LanguageHelper:GetText(10404)
end
function M.BuyDone(self)
    --显示：购买成功
    self.insts.Task.onLineTime.Text=LanguageHelper:GetText(30013)
    self.insts.Task.progress.Size=UDim2.fromScale(1,1)
end
function M.dtor(self)
	M.super.dtor(self);
end;

return M;